import 'package:flutter/material.dart';
import 'package:we_chat_app/chat_page.dart';
import 'package:we_chat_app/const.dart';
import 'package:we_chat_app/login/login.dart';
import 'package:we_chat_app/my_cell.dart';

class MyPage extends StatefulWidget {

  @override
  State createState() {
    return MyPageState();
  }
}

class MyPageState extends State<MyPage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: contextColor,
        child: Stack(
          children: [
            // 列表
            Container( child:
            MediaQuery.removePadding(
                context: context,
                removeTop: true,
                child: ListView(
              children: [
                HeadWidget(),
                const SizedBox(height: 5),
                const MyCell(image: 'images/rili.png', title: '日历', subTitle: '', subImage: ''),
                const SizedBox(height:5),
                const MyCell(image: 'images/tianqi.png', title: '天气', subTitle: '', subImage: ''),
                const SizedBox(height:5),
                const MyCell(image: 'images/yunshequ.png', title: '云社区', subTitle: '', subImage: ''),
                const SizedBox(height:5),
                const MyCell(image: 'images/zhandian.png', title: '位置', subTitle: '', subImage: ''),
                const SizedBox(height:5),
                const MyCell(image: 'images/zixunjieda.png', title: '问答', subTitle: '', subImage: ''),
                const SizedBox(height:5),
                const MyCell(image: 'images/shezhi.png', title: '设置', subTitle: '', subImage: ''),
              ],
            ))),
            // 相机
            const Positioned(
                right: 20,
                top: 60,
                child: Image(image: AssetImage('images/saoma.png'),width: 40,),
            )
          ],
        ),
      ),
    );
  }
}

class HeadWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return  Container(
      padding: EdgeInsets.only(left: 16,top: 100,right: 16,bottom: 10),
      color: Colors.white,
      child: GestureDetector(
        onTap: () {
          Navigator.push(context, MaterialPageRoute(builder: (newPage) {
            return LoginPage();
          }));
        },
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              children: [Container(
                width: 70,
                height: 70,
                clipBehavior: Clip.hardEdge,
                margin: const EdgeInsets.all(5),
                decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(5),
                    image: const DecorationImage(
                        image: AssetImage('images/heads.png')
                    )
                ),
              ),const Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text('Justin', style: TextStyle(color: Colors.black,fontSize: 30,fontWeight: FontWeight.bold), ),
                  Text('飞一样的感觉......',style: TextStyle(fontSize: 15),)],
              )],
            ),
            Container(
              child: Icon(Icons.chevron_right,color: Colors.grey,),
            )
          ],
        ),
      )
      );
  }



}


